﻿using Application.ProductApp;
using Application.ProductTypeApp;
using Domain.Entities;
using JFnetcore.Models.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace JFnetcore.CS
{
    public class vProductHelp
    {
        public List<vProduct> GetVProductList(List<Product> productlist, List<ProductType> producttypelist)
        {
            var vlist = from a in productlist
                        join b in producttypelist
                        on a.ProductType_Id equals b.Id
                        where a.Disable != 0
                        select new
                        {
                            Product_Id=a.Id,
                            Product_name = a.Product_name,
                            Product_No = a.Product_No,
                            Product_Createtime = a.Createtime,
                            Product_url = a.Product_url,
                            Product_txt = a.Product_txt,
                            productType_Name = b.ProductType_name,
                            ProductType_id = b.Id,
                            Product_disable =a.Disable

                        };
            return vlist.ToList().Select(C => new vProduct
            {
                Product_id = C.Product_Id,
                Product_name = C.Product_name,
                Product_No = C.Product_No,
                Product_Createtime = C.Product_Createtime,
                Product_url = C.Product_url,
                Product_txt = C.Product_txt,
                ProductType_name = C.productType_Name,
                ProductType_id = C.ProductType_id,
                Product_disable =C.Product_disable
            }).ToList();
        }
    }
}
